Refactoring Duplicate Code